<template>
	<div class="boxmain">
		<h3 class="titlelist">
			总分成绩信息
			<div>
				<i @click="importModel">导入模板</i>
				<!-- <i >批量导入</i> -->
				<p class="uploadImages1">
					<span>批量导入</span>
					<input type="file" @change="changeImg">
				</p>
				<i @click="modifypl">批量修改</i>
				<i @click="reassignpoints">重新赋分</i>
				<i style="color:red;" @click="batchDelete">批量删除</i>
			</div>
		</h3> 
		<div class="chooseschool">
			<div>
				选择查看学校
				<el-select v-model="searchschool" placeholder="全部" @change="schoollistchange">
					<el-option
					  key="全部"
					  label="全部"
					  value="全部">
					</el-option>
				  <el-option
				    v-for="item in schoolList"
				    :key="item.gradeId"
				    :label="item.schoolName"
				    :value="item.gradeId">
				  </el-option>
				</el-select>
			</div>
			<div>
				查找准考证号
				<el-input v-model="zkzh" placeholder="准考证号"></el-input>
				<b class='el-icon-search' @click="zkzhclick"></b>
			</div>
			<div>
				查找姓名
				<el-input v-model="studentName" placeholder="学生姓名"></el-input>
				<b class='el-icon-search' @click="studentclick"></b>
			</div>
		</div>
		<div class="table-container" ref="scrollContainer" :style="{height:tableheight+'px'}"  v-if="studentData.length!=0">
			<table :style="{width:parseInt(19*120)+'px'}">
				<thead>
					<tr>
						<th width="50">
							 <input type="checkbox" v-model="selectAll" @change="toggleSelectAll">
						</th>
						<th width="120">准考证号</th>
						<th width="100">姓名</th>
						<th width="300">学校</th>
						<th width="100">班级</th>
						<th width="100">总分</th>
						<th width="100">总分(赋分)</th>
						<th width="80">语文</th>
						<th width="80">数学</th>
						<th width="80">英语</th>
						<th width="80">物理</th>
						<th width="100" v-if="titlecontent.type3!=2">物理(赋分)</th>
						<th width="80">化学</th>
						<th width="100">化学(赋分)</th>
						<th width="80">生物</th>
						<th width="100">生物(赋分)</th>
						<th width="80">历史</th>
						<th width="100" v-if="titlecontent.type3!=2">历史(赋分)</th>
						<th width="80">地理</th>
						<th width="100">地理(赋分)</th>
						<th width="80">政治</th>
						<th width="100">政治(赋分)</th>
						<th width="80">日语</th>
						<th class="sticky-col" ref="mytd" style="padding:0;overflow: hidden;padding-left:2px;">
							<div ref="mydiv" class="boxdivposition" style="position:relative;z-index:1000;width:100%;padding:10px;box-shadow: -2px 0px 0px rgba(0,0,0,0.1);" :style="{height:tdheight}">
								操作
							</div>
						</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="item in studentData">
						<td style="width:40px;">
							<input type="checkbox" v-model="selectedItems" :value="item.id">
						</td>
						<td>{{item.userNumber?item.userNumber:item.examNumber}}</td>
						<td>{{item.studentName}}</td>
						<td>{{item.school}}</td>
						<td>{{item.className}}</td>
						<td>{{item.allScore}}</td>
						<td>{{item.allScoreff}}</td>
						<td>{{item.ywScore}}</td>
						<td>{{item.sxScore}}</td>
						<td>{{item.yyScore}}</td>
						<td>{{item.wlScore}}</td>
						<td v-if="titlecontent.type3!=2">{{item.wlffScore}}</td>
						<td>{{item.hxScore}}</td>
						<td>{{item.hxffScore}}</td>
						<td>{{item.swScore}}</td>
						<td>{{item.swffScore}}</td>
						<td>{{item.lsScore}}</td>
						<td v-if="titlecontent.type3!=2">{{item.lsffScore}}</td>
						<td>{{item.dlScore}}</td>
						<td>{{item.dlffScore}}</td>
						<td>{{item.zzScore}}</td>
						<td>{{item.zzffScore}}</td>
						<td>{{item.ryScore}}</td>
						<td class="sticky-col" style="padding:0;padding-left:2px;">
							<div :class="titlecontent.createType==0?'width240':'width190'">
								<span @click="lookcard(item.examNumber)" v-if="item.type==0">答题卡</span>
								<span @click="fixedchengji(item)">修改成绩</span>
								<span @click="missanexam(item.examNumber)" style="color:#EA0000">缺考</span>
								<span @click="deletcard(item.id)">删除</span>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div v-else class="emptyBox">
			<p>
				<img src="../../../assets/image/empty.png" alt="">
				<span>抱歉，当前栏目下没有内容！</span>
			</p>
		</div>
		<div v-if="studentData.length>0" class="boxpagelist">
			<span class="colorGray">已选中{{selectedItems.length}}条，</span>
			<span class="colorGray">共{{listTotal}}条数据</span>
			<el-pagination
			      @size-change="handleSizeChange"
			      @current-change="handleCurrentChange"
			      :current-page="pageIndex"
			      :page-sizes="[20, 50, 100]"
			      :page-size="pageSize"
			      layout="total, sizes, prev, pager, next, jumper"
				  background
			      :total="listTotal?listTotal:0">
			    </el-pagination>
		</div>
		<!-- 修改成绩信息  -->
		<div class="addExamMain" v-if="fixedchengjiIshow">
			<div class="addExamContent">
				<h3>修改成绩信息</h3>
				<ul>
					<li>
						<span>总分</span>
						<el-input v-model="studentinfo.allscore" disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>总分（赋分）</span>
						<el-input v-model="studentinfo.allscoreff" disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>语文</span>
						<el-input v-model="studentinfo.ywscore" @input="studentinfo.ywscore = $event.replace(/[^0-9+\-*/\.]/g, '')" clearable placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>数学</span>
						<el-input v-model="studentinfo.sxscore" clearable @input="studentinfo.sxscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>英语</span>
						<el-input v-model="studentinfo.yyscore" clearable @input="studentinfo.yyscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>物理</span>
						<el-input v-model="studentinfo.wlscore" clearable @input="studentinfo.wlscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li v-if="titlecontent.type3!=2">
						<span>物理（赋分）</span>
						<el-input v-model="studentinfo.wlffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>化学</span>
						<el-input v-model="studentinfo.hxscore" clearable @input="studentinfo.hxscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>化学（赋分）</span>
						<el-input v-model="studentinfo.hxffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>生物</span>
						<el-input v-model="studentinfo.swscore" clearable @input="studentinfo.swscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>生物（赋分）</span>
						<el-input v-model="studentinfo.swffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>历史</span>
						<el-input v-model="studentinfo.lsscore" clearable @input="studentinfo.lsscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li v-if="titlecontent.type3!=2">
						<span>历史（赋分）</span>
						<el-input v-model="studentinfo.lsffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>地理</span>
						<el-input v-model="studentinfo.dlscore" clearable @input="studentinfo.dlscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>地理（赋分）</span>
						<el-input v-model="studentinfo.dlffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>政治</span>
						<el-input v-model="studentinfo.zzscore" clearable @input="studentinfo.zzscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>政治（赋分）</span>
						<el-input v-model="studentinfo.zzffscore" clearable disabled placeholder="请输入内容"></el-input>
					</li>
					<li>
						<span>日语</span>
						<el-input v-model="studentinfo.ryscore" clearable @input="studentinfo.ryscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"></el-input>
					</li>
				</ul> 
				<div class="groupbutton">
					<el-button type="primary" @click="sureModify">保存</el-button>
					<el-button type="primary" @click="modifycj">返回</el-button> 
				</div>
			</div>
		</div>
		<!-- 缺考 -->
		<div class="missanexam" v-if="missanexamIshow">
			<h3><i class="el-icon-warning-outline"></i>请选择缺考科目</h3>
			<p>该名考生的缺考科目将不参与分析，已有成绩会归零！</p>
			<el-checkbox-group v-model="checkList">
				<el-checkbox v-for="item in qkxuekelist" :label="titlecontent.type3==3?item.id:item.navid" :key="titlecontent.type3==3?item.id:item.navid">{{titlecontent.type3==3?item.name:item.subjectname}}</el-checkbox>
		  </el-checkbox-group>
		  <div class="boxbutton">
			  <el-button type="primary" @click="misssure">确定</el-button>
			  <el-button type="info" @click="missanexamIshow=false">取消</el-button> 
		  </div>
		</div>
		<!-- 答题卡 -->
		<div class="missanexam" v-if="cardexamIshow">
			<h3><i class="el-icon-warning-outline"></i>请选择查看答题卡科目</h3>
			<el-radio-group v-model="cardradio">
			    <el-radio v-for="item in xuekelist" :label="item.id" :key="item.id" >{{item.name}}</el-radio>
			</el-radio-group>
		  <div class="boxbutton">
			  <el-button type="primary" @click="cardlooksure">确定</el-button>
			  <el-button type="info" @click="cardexamIshow=false">取消</el-button> 
		  </div>
		</div>
		<!-- 批量修改 -->
		<div class="batchModifyMain" v-if="modyifyplIshow"> 
			<div class="batchModifyContent">
				<h3>批量修改</h3>
				<div class="modifyThreetab">
					<p :class="modifytab==1?'hover':''" @click="schoolmodify(1)">指定范围修改</p>
					<p :class="modifytab==2?'hover':''" @click="schoolmodify(2)">固定范围修改</p>
				</div>
				<div>
					<ul>
						<li v-if="modifytab!=1">
							<span>修改范围</span>
							<el-select v-model="jbtype" placeholder="请选择" @change="modifyfanwei">
							  <el-option
							    v-for="item in jibielist"
							    :key="item.id"
							    :label="item.name"
							    :value="item.id">
							  </el-option>
							</el-select>
						</li> 
						<li v-if="jbtype==2">
							<span>学校名称多选</span>
							<el-select v-model="schoolName" clearable multiple placeholder="请选择">
							  <el-option
							    v-for="item in schoolList"
							    :key="item.gradeId"
							    :label="item.schoolName"
							    :value="item.gradeId">
							  </el-option>
							</el-select>
						</li>
						<li v-if="jbtype==3">
							<span>学校名称单选</span>
							<el-select v-model="schoolNameId" clearable placeholder="请选择" @change="getschoolclass">
							  <el-option
							    v-for="item in schoolList"
							    :key="item.gradeId"
							    :label="item.schoolName"
							    :value="item.gradeId">
							  </el-option>
							</el-select>
						</li>
						<li v-if="jbtype===3">
							<span>班级名称</span>
							<el-select v-model="className" clearable multiple placeholder="请选择" @focus="classIf">
							  <el-option
							    v-for="item in classDate"
							    :key="item.id"
							    :label="item.name"
							    :value="item.id">
							  </el-option>
							</el-select>
						</li>
						<li v-if="modifytab===1">
							<span>准考证号</span>
							<el-input v-model="modifystudentinfo.batchStudentScore.userNumber" @input="modifystudentinfo.batchStudentScore.userNumber = $event.replace(/[^0-9#\.]/g, '')" clearable type="textarea" placeholder="输入多个准考证号以#分隔"></el-input>
						</li>
						<li>
							<span>总分</span>
							<el-input v-model="allscore" disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>总分（赋分）</span>
							<el-input v-model="allffscore" disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>语文</span>
							<el-input v-model="ywscore" clearable @input="ywscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('语文', $event)"></el-input>
						</li>
						<li>
							<span>数学</span>
							<el-input v-model="sxscore" clearable @input="sxscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('数学', $event)"></el-input>
						</li>
						<li>
							<span>英语</span>
							<el-input v-model="yyscore" clearable @input="yyscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('英语', $event)"></el-input>
						</li>
						<li>
							<span>物理</span>
							<el-input v-model="wlscore" clearable @input="wlscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('物理', $event)"></el-input>
						</li>
						<li>
							<span>物理（赋分）</span>
							<el-input v-model="wlffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>化学</span>
							<el-input v-model="hxscore" clearable @input="hxscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('化学', $event)"></el-input>
						</li>
						<li>
							<span>化学（赋分）</span>
							<el-input v-model="hxffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>生物</span>
							<el-input v-model="swscore" clearable @input="swscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('生物', $event)"></el-input>
						</li>
						<li>
							<span>生物（赋分）</span>
							<el-input v-model="swffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>历史</span>
							<el-input v-model="lsscore" clearable @input="lsscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字" @change="updateScore('历史', $event)"></el-input>
						</li>
						<li>
							<span>历史（赋分）</span>
							<el-input v-model="lsffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>地理</span>
							<el-input v-model="dlscore" clearable @input="dlscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字"  @change="updateScore('地理', $event)"></el-input>
						</li>
						<li>
							<span>地理（赋分）</span>
							<el-input v-model="dlffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>政治</span>
							<el-input v-model="zzscore" clearable @input="zzscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请填写符号加数字"  @change="updateScore('政治', $event)"></el-input>
						</li>
						<li>
							<span>政治（赋分）</span>
							<el-input v-model="zzffscore" clearable disabled placeholder="请填写符号加数字"></el-input>
						</li>
						<li>
							<span>日语</span>
							<el-input v-model="ryscore" clearable @input="ryscore = $event.replace(/[^0-9+\-*/\.]/g, '')" placeholder="请输入内容"  @change="updateScore('日语', $event)"></el-input>
						</li>
					</ul> 
					<div class="groupbutton">
						<el-button type="primary" @click="modifyplsure">保存</el-button>
						<el-button type="primary" @click="modifyplback">返回</el-button> 
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		analysisAllScoreDirectionRank,
		groupExamList,
		studentscoreimport,
		navgetgrade,
		lookcardlist,
		deletestudentscore,
		selectstudentsubject,
		missexamedit,
		studentmodifyscore,
		groupcalssList,
		reassignpointss
	} from '../../../api/scoreapi.js'
	export default{
		data(){
			return{
				jibielist:[
					{id:4,name:'联考'},
					{id:2,name:'校级'},
					{id:3,name:'班级'}
				],
				jbtype:4,
				searchschool:'全部',
				tableData: [],
				columns: [
				        { data:'date', label:'总分(赋)', width: 180},
						{ data:'name', label:'数学', width: 180 },
				      ],
				tableheight:'',
				fixedchengjiIshow:false,
				studentinfo:{
					id:'',
					allscore:'',
					allffscore:'',
					ywscore:'',
					sxscore:'',
					yyscore:'',
					wlscore:'',
					wlffscore:'',
					hxscore:'',
					hxffscore:'',
					swscore:'',
					swffscore:'',
					lsscore:'',
					lsffscore:'',
					dlscore:'',
					dlffscore:'',
					zzscore:'',
					zzffscore:'',
					ryscore:'',
				},
				photo:[],
				checkList:[],
				missanexamIshow:false,
				modifytab:1,
				modyifyplIshow:false,
				multipleSelection:[],
				cardexamIshow:false,
				studentData:[],
				titlecontent:{},
				zkzh:'',
				studentName:'',
				schoolList:[],
				xuekelist:[],
				cardradio:'',
				xszkzh:'',
				qkxuekelist:[],
				pageIndex:1,
				pageSize:20,
				 selectedItems: [],
				 allscore:'',
				 allffscore:'',
				 ywscore:'',
				 sxscore:'',
				 yyscore:'',
				 wlscore:'',
				  wlffscore:'',
				 hxscore:'',
				 hxffscore:'',
				 swscore:'',
				 swffscore:'',
				 lsscore:'',
				 lsffscore:'',
				 dlscore:'',
				 dlffscore:'',
				 zzscore:'',
				 zzffscore:'',
				 ryscore:'',
				 schoolNameId:'',
				 className:'',
				 schoolName:'',
				 modifystudentinfo:{
					 updateType:2,
					 batchStudentScore: {
						 gradeId:[],
						 classId:[],
						 userNumber:'',
						 type:'',
						 n5Id:'',
						 subjectCalculateList:[]
					 }
				 },
				 classDate:[],
				 listTotal:'',
				tdheight:''
			}
		},
		created() {
			
		},
		mounted() {
			// 在组件挂载后获取屏幕高度
			let newtitle = decodeURIComponent(this.$route.query.con)
			this.titlecontent = JSON.parse(newtitle)
			this.getStudentAchievement(this.titlecontent.n5Id)
			this.getScreenHeight();
			//在窗口大小变化时更新屏幕高度，可以监听window的resize事件
			window.addEventListener('resize', this.getScreenHeight);
			localStorage.setItem('menuState', 2);
			this.getSchoolList()
			
		},
		methods: {
			validateInput(value) {
				console.info(value)
			      // 正则表达式：匹配数字、加减乘除运算符、小数点，以及防止连续的小数点或运算符
			      const regex = /[0-9+-\.*/]?$/;
			
			      // 如果输入不符合正则表达式，则去除最后一个字符
				  console.info(regex.test(value))
			      if (!regex.test(value)) {
			        this.studentinfo.ywscore = value.slice(0, -1);
			      } else {
			        // 输入合法，不需要做任何处理
			        this.studentinfo.ywscore = value;
			      }
			    },
			updateScore(field, event) {
				let fhao = this.determineSign(event)
				let params={
					subject:field,
					score:event.substring(1),
					type:this.determineSign1(fhao)
				}
				const index = this.modifystudentinfo.batchStudentScore.subjectCalculateList.findIndex(item => item.subject === params.subject)
				// 如果存在，则删除旧的数据条目
				if (index !== -1) {
				  this.modifystudentinfo.batchStudentScore.subjectCalculateList.splice(index, 1);
				}
				// 检查score是否为空
				if (params.score.trim() === '') {
					return; // 退出方法，不执行后续添加操作
				}
				// 添加最新的数据到数组中
				  this.modifystudentinfo.batchStudentScore.subjectCalculateList.push({
					...params // 使用解构来复制对象，确保不是引用同一个对象
				  });
				console.info(this.modifystudentinfo.batchStudentScore.subjectCalculateList)
				  // // 从输入中移除任何非数字字符（假设只想要数字作为分数）
				  // const score = event.target.value.replace(/\D/g, '');
				  // // 更新实际存储的分数
				  // this.modifystudentinfo[field] = score;
				  // // 更新显示的分数，加上学科前缀
				  // this.modifystudentinfo.hxscoreDisplay = `化学: ${score}`;
			},
			determineSign(value) {
				  const firstChar = value.charAt(0); // 获取字符串的第一个字符
				  switch (firstChar) {
					case '+':
					  return '加号';
					case '-':
					  return '减号';
					case '*':
					  return '乘号';
					case '/':
					  return '除号';
					default:
					  return '未知符号';
				  }
				},
				determineSign1(fhao) {
				  switch (fhao) {
					case '加号':
					  return 1;
					case '减号':
					  return 2;
					case '乘号':
					  return 3;
					case '除号':
					  return 4;
					default:
					  return undefined;
				  }
				},
				// 处理每页条数变化
				handleSizeChange(val){
					this.pageSize = val
					this.getStudentAchievement(this.titlecontent.n5Id)
				},
				// 处理当前页码变化
				handleCurrentChange(val){
					this.pageIndex = val
					this.getStudentAchievement(this.titlecontent.n5Id)
				},
				// calculateIsLastPage() {
				//   const lastPage = Math.ceil(this.listTotal / this.pageSize);
				//   const isLastPage = this.pageIndex === lastPage;
				 
				//   if(isLastPage){
				// 	  this.currentPagetotal = this.listTotal
				//   }else{
				// 	 this.currentPagetotal = this.pageSize*this.pageIndex
				//   }
				//   // 根据isLastPage的值做相应处理
				// },
			//获取总分成绩列表
			getStudentAchievement(n5id) {
			  let obj = {
			    navId:n5id,
			    stuNameOrExamNo: this.zkzh?this.zkzh:undefined,
				studentName:this.studentName?this.studentName:undefined,
			    groupType: 2,
			    navType: 1,
				groupId:this.searchschool==''||this.searchschool=='全部'?undefined:this.searchschool,
				pageIndex:this.pageIndex,
				pageSize:this.pageSize
			  }
			  analysisAllScoreDirectionRank(obj).then(res => {
				  console.info(res.data.length+'ddddd')
				  
				   if(res.data.length<=0){
					   this.selectAll = !this.selectAll
					   this.listTotal=0
					   this.pageIndex=1
					   // console.info(this.selectAll)
					   return false
				   }
				   this.studentData=res.data   
				   if(this.pageIndex==1){
					   this.listTotal = res.data[0].total
					   sessionStorage.setItem('total',res.data[0].total)
					   
				   }else{
					   this.listTotal = Number(sessionStorage.getItem('total'))
				   }
				    
			  })
			},
			//获取学校列表
			getSchoolList() {
			  groupExamList({navId: this.titlecontent.n5Id}).then(res => {
			    this.schoolList = res.data
			  })
			},
			schoollistchange(val){
				this.studentData=[]
				this.pageIndex=1
				this.getStudentAchievement(this.titlecontent.n5Id)
			},
			handleVisibleChange(visible) {
			    console.log('Dropdown visibility changed:', visible);
			  },
		    getScreenHeight() {
		      // 获取屏幕高度并更新data中的screenHeight
		      this.tableheight = parseInt(window.innerHeight-340);
		    },
			studentclick(){
				this.studentData=[]
				this.pageIndex=1
				this.getStudentAchievement(this.titlecontent.n5Id)
			},
			zkzhclick(){
				this.studentData=[]
				this.pageIndex=1
				this.getStudentAchievement(this.titlecontent.n5Id)
			},
			//修改成绩
			fixedchengji(con){
				this.fixedchengjiIshow=true
				this.studentinfo.id = con.id
				this.studentinfo.allscore=con.allScore
				this.studentinfo.allffscore=con.allffScore
				this.studentinfo.ywscore=con.ywScore
				this.studentinfo.sxscore=con.sxScore
				this.studentinfo.yyscore=con.yyScore
				this.studentinfo.wlscore=con.wlScore
				this.studentinfo.wlffscore=con.wlffScore
				this.studentinfo.hxscore=con.hxScore
				this.studentinfo.hxffscore=con.hxffScore
				this.studentinfo.swscore=con.swScore
				this.studentinfo.swffscore=con.swffScore
				this.studentinfo.lsscore=con.lsScore
				this.studentinfo.lsffscore=con.lsffScore
				this.studentinfo.dlscore=con.dlScore
				this.studentinfo.dlffscore=con.dlffScore
				this.studentinfo.zzscore=con.zzScore
				this.studentinfo.zzffscore=con.zzffScore
				this.studentinfo.ryscore=con.ryScore
			},
			//返回
			modifycj(){
				this.studentinfo.id = ''
				this.studentinfo.allscore= ''
				this.studentinfo.allffscore= ''
				this.studentinfo.ywscore= ''
				this.studentinfo.sxscore= ''
				this.studentinfo.yyscore= ''
				this.studentinfo.wlscore= ''
				this.studentinfo.wlffscore= ''
				this.studentinfo.hxscore= ''
				this.studentinfo.hxffscore= ''
				this.studentinfo.swscore= ''
				this.studentinfo.swffscore= ''
				this.studentinfo.lsscore= ''
				this.studentinfo.lsffscore= ''
				this.studentinfo.dlscore= ''
				this.studentinfo.dlffscore= ''
				this.studentinfo.zzscore= ''
				this.studentinfo.zzffscore= ''
				this.studentinfo.ryscore=''
				this.fixedchengjiIshow=false
			},
			//保存成绩
			sureModify(){
				this.studentinfo.updateType = 1
				console.info(this.studentinfo)
				studentmodifyscore(this.studentinfo).then(res=>{
					if(res.code==0){
						this.pageIndex = 1
						this.studentData = []
						this.studentinfo={
							id:'',
							allscore:'',
							allffscore:'',
							ywscore:'',
							sxscore:'',
							yyscore:'',
							wlscore:'',
							wlffscore:'',
							hxscore:'',
							hxffscore:'',
							swscore:'',
							swffscore:'',
							lsscore:'',
							lsffscore:'',
							dlscore:'',
							dlffscore:'',
							zzscore:'',
							zzffScore:'',
							ryscore:'',
						}
						this.$message({
							type: 'success',
							message: '修改成功'
						}); 
						this.getStudentAchievement(this.titlecontent.n5Id)
						this.fixedchengjiIshow=false
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			//table各色换行
			tableRowClassName({row, rowIndex}) {
				return rowIndex % 2 === 0 ? 'warning-row' : 'success-row'
			},
			//获取学科列表
			xuekeclick(areaid){
				let params={
					ntype:6,
					id:areaid
				}
				navgetgrade(params).then(res=>{
					if(res.code==0){
						this.xuekelist = res.data
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			lookcard(examNumber){
				this.xuekeclick(this.titlecontent.n5Id)
				this.xszkzh= examNumber
				this.cardexamIshow = true
			},
			//选择查看答题卡
			cardlooksure(){
				console.info(this.cardradio)
				let params={
					navId:this.cardradio,
					stuNameOrExamNo:this.xszkzh
				}
				lookcardlist(params).then(res=>{
					console.info(res)
					if(res.code==0){
						if(res.data.length<=0){
							this.$message({
								type: 'error',
								message: '该学生没有答题卡'
							}); 
							this.cardexamIshow = false
						}else{
							let photo=[]
							if(res.data[0].cardfront2!=null){
								photo.push(this.$imgUrl1+res.data[0].cardfront2)
								// console.info(this.$imgUrl1+res.data[0].cardfront2)
							}else{
								photo.push(this.$imgUrl3+res.data[0].cardfront)
							}
							if(res.data[0].cardreverse2!=null){
								photo.push(this.$imgUrl1+res.data[0].cardreverse2)
							}else{
								photo.push(this.$imgUrl3+res.data[0].cardreverse)
							}
							this.photo = photo
							const $viewer = this.$viewerApi({
								images: photo
							})
							this.cardexamIshow = false
						}
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
				
			},
			// 缺考
			missanexam(examid){
				this.missanexamIshow = true
				this.examcardid=examid
				if(this.titlecontent.type3==3){
					let params={
						ntype:6,
						id:this.titlecontent.n5Id
					}
					navgetgrade(params).then(res=>{
						console.info(params)
						if(res.code==0){
							this.qkxuekelist = res.data
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							}); 
						}
						
					})
				}else{
					let params={
						navId:this.titlecontent.n4Id,
						stuNameOrExamNo:examid
					}
					selectstudentsubject(params).then(res=>{
						console.info(params)
						if(res.code==0){
							this.qkxuekelist = res.data
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							}); 
						}
						
					})
				}
				
			},
			//编辑缺考
			misssure(){
				this.missanexamIshow = false
				let params={
					userNumber:this.examcardid,
					subjectIds:this.checkList
				}
				missexamedit(params).then(res=>{
					if(res.code==0){
						this.$message({
							type: 'success	',
							message: res.msg
						}); 
						this.getStudentAchievement(this.titlecontent.n5Id)
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						}); 
					}
				})
			},
			//tab切换
			schoolmodify(num){
				if(num===2){
					this.getSchoolList()
				}
				this.jbtype=4
				this.modifytab = num
				this.allscore=''
				this.allffscore=''
				this.ywscore=''
				this.sxscore=''
				this.yyscore=''
				this.wlscore=''
				 this.wlffscore=''
				this.hxscore=''
				this.hxffscore=''
				this.swscore=''
				this.swffscore=''
				this.lsscore=''
				this.lsffscore=''
				this.dlscore=''
				this.dlffscore=''
				this.zzscore=''
				this.zzffscore=''
				this.ryscore=''
				this.schoolNameId=""
				this.className=""
				this.schoolName=""
				this.modifystudentinfo={
					 updateType:2,
					 batchStudentScore: {
						 gradeId:[],
						 classId:[],
						 userNumber:'',
						 type:'',
						 n5Id:'',
						 subjectCalculateList:[]
					 }
				}
			},
			//批量修改
			modifypl(){
				this.modyifyplIshow= true
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			// 批量删除
			batchDelete(){
				let params={
					ids:this.selectedItems
				}
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(() => {
					deletestudentscore(params).then(res=>{
						if(res.code==0){
							this.studentData = []
							this.selectAll =false
							this.getStudentAchievement(this.titlecontent.n5Id)
							this.$message({
								type: 'success',
								message: '删除成功!'
							});
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							});
						}
					})
				  
				}).catch(() => {
				  this.$message({
					type: 'info',
					message: '已取消删除'
				  });          
				});
			},
			//导入模板
			importModel(){
				const a = document.createElement('a');
				// 设置下载链接和文件名
				a.href = 'https://oss.bslmedu.com/yuejuan/%E5%AF%BC%E5%85%A5%E6%88%90%E7%BB%A9%E6%A8%A1%E6%9D%BF.xlsx';
				a.download = '导入成绩模板'
				// 模拟点击事件以触发下载
				a.click();
				// 清理：移除创建的<a>元素
				document.body.removeChild(a);
			},
			// 批量导入成绩
			changeImg(e){
				const files = e.target.files;
				if (files.length === 0) {
					// 没有选择文件，用户可能点击了取消
					return;
				}
				let params={
					navId:this.titlecontent.n5Id,
					file:e.target.files[0]
				}
				studentscoreimport(params).then(res=>{
					this.$message({
						type: 'success',
						message: res.msg
					}); 
					this.getStudentAchievement(this.titlecontent.n5Id)
					this.getSchoolList()
				})
			},
			//删除成绩deletcard
			deletcard(id){
				let params={
					ids:[id]
				}
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(() => {
					deletestudentscore(params).then(res=>{
						if(res.code==0){
							this.getStudentAchievement(this.titlecontent.n5Id)
							this.$message({
								type: 'success',
								message: '删除成功!'
							});
						}else{
							this.$message({
								type: 'error',
								message: res.msg
							});
						}
					})
				  
				}).catch(() => {
				  this.$message({
					type: 'info',
					message: '已取消删除'
				  });          
				});
			},
			deleteSelectedItems() {
			  // 删除选中的项目
			  this.studentData = this.studentData.filter(item => !this.selectedItems.includes(item.id));
			  console.info(this.studentData)
			  // 清空选中的项目数组
			  this.selectedItems = [];
			  // 取消全选状态
			   this.selectAll = false;
			},
			removeItem(index) {
			  // 删除项目
			  this.studentData.splice(index, 1);
			  // 更新选中的项目数组
			  this.selectedItems = this.selectedItems.filter(id => {
				return this.studentData.some(item => item.id === id);
			  });
			},
			// 切换全选状态
			toggleSelectAll() {
			  if (this.selectAll) {
				// 如果全选，则将所有项的ID添加到selectedIds中
				this.selectedIds = this.studentData.map(item => item.id);
			  } else {
				// 如果取消全选，则清空selectedIds
				this.selectedIds = [];
			  }
			},
			//点击修改范围清校级联动
			modifyfanwei(){
				this.modifystudentinfo.batchStudentScore.gradeId=[]
			},
			//批量修改保存
			modifyplsure(){
				this.modifystudentinfo.batchStudentScore.classId=this.className.length>0?this.className:undefined
				this.modifystudentinfo.batchStudentScore.gradeId=this.schoolName.length>0?this.schoolName:undefined
				this.modifystudentinfo.batchStudentScore.userNumber = this.modifystudentinfo.batchStudentScore.userNumber?this.modifystudentinfo.batchStudentScore.userNumber:undefined
				this.modifystudentinfo.batchStudentScore.type=this.modifytab==1?this.modifytab:this.jbtype
				this.modifystudentinfo.batchStudentScore.n5Id = this.titlecontent.n5Id
				this.studentData=[]
				// if(this.modifystudentinfo.batchStudentScore.subjectCalculateList.length<0){
				// 	this.$message({
				// 		type: 'error',
				// 		message: '至少选择一个学科'
				// 	});
				// 	return false
				// }
				// return false
				studentmodifyscore(this.modifystudentinfo).then(res=>{
					this.modyifyplIshow=false
					this.$message({
						type: 'success',
						message: '修改成功!'
					});
					this.pageIndex = 1
					this.getStudentAchievement(this.titlecontent.n5Id)
				})
			},
			//批量修改返回
			modifyplback(){
				this.modyifyplIshow=false
				this.allscore=''
				this.allffscore=''
				this.ywscore=''
				this.sxscore=''
				this.yyscore=''
				this.wlscore=''
				 this.wlffscore=''
				this.hxscore=''
				this.hxffscore=''
				this.swscore=''
				this.swffscore=''
				this.lsscore=''
				this.lsffscore=''
				this.dlscore=''
				this.dlffscore=''
				this.zzscore=''
				this.zzffscore=''
				this.ryscore=''
				this.schoolNameId=""
				this.className=""
				this.schoolName=""
				this.modifystudentinfo={
					 updateType:2,
					 batchStudentScore: {
						 schoolName:[],
						 className:[],
						 userNumber:'',
						 type:'',
						 n5Id:'',
						 subjectCalculateList:[]
					 }
				}
			},
			// 获取班级列表
			getclassList(gradeid){
				let params={
					id:gradeid
				}
				groupcalssList(params).then(res=>{
					if(res.code==0){
						console.info(res)
						this.classDate=res.data
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						});
					}
				})
			},
			//点击学校下拉获取年纪$("#")
			getschoolclass(val){
				// this.modifystudentinfo.batchStudentScore.gradeId = [val]
				this.getclassList(val)
			},
			//点击班级下拉判断校级是否选择否则提示
			classIf(){
				if(this.modifystudentinfo.batchStudentScore.schoolNameId==''){
					this.$message({
						type: 'error',
						message: '请先选择校级列表'
					});
				}
			},
			//重新赋分
			reassignpoints(){
				let params={
					navId:this.titlecontent.n5Id
				}
				reassignpointss(params).then(res=>{
					if(res.code==0){
						this.getStudentAchievement(this.titlecontent.n5Id)
					}else{
						this.$message({
							type: 'error',
							message: res.msg
						});
					}
				})
			}
		},
		beforeDestroy() {
			// 在组件销毁前移除事件监听器，避免内存泄漏
			window.removeEventListener('resize', this.getScreenHeight);
			this.$refs.scrollContainer.removeEventListener('scroll', this.handleScroll)
		},
		computed: {
			selectAll: {
				get: function () {
					if(this.studentData.length<=0){
						return false
					}else{
						return this.studentData.length === this.selectedItems.length;
					}
				},
				set: function (value) {
					if (value) {
					  // 选中所有
					  if(this.studentData.length<=0){
					  	return false
					  }else{
					  	this.selectedItems = this.studentData.map(item => item.id);
					  }
					} else {
					  // 取消选中
					  this.selectedItems = [];
					}
				}
			}
		},
	}
</script>

<style scoped>
	.titlelist{
		padding:0 0 20px;
		font-size:18px;
		display: flex;
		justify-content: space-between;
	}
	.titlelist>>> .el-button{
		background:#165DFF
	}
	.titlelist div{
		 font-size:14px;
		 color:#1664FF;
		 font-style: normal;
		 font-weight: normal;
		 display: flex;
		 align-items: center;
	}
	.titlelist div i{
		display: inline-block;
		margin-left:20px;
		cursor: pointer;
		font-style:normal;
	}
	.titlelist div p{
		margin-left:20px;
	}
	.boxmain{
		padding:30px 30px 0;
	}
	.addstudent{
		display: flex;
		justify-content: space-between;
		padding-bottom:15px;
		font-size:18px;
		font-weight:bold;
	}
	.addstudent b{
		font-weight:normal;
		color:#1664FF;
		cursor: pointer;
		font-size:14px;   
	}
	.chooseschool{
		margin-bottom:15px;
		display: flex;
		align-items: center;
	}
	.chooseschool >>> .el-select{
		margin-left:10px;
	}
	.addExamMain,.batchModifyMain{
		position: fixed;
		width:100%;
		height:100%;
		background:rgba(0,0,0,0.5);
		left:0;
		top:0;
		z-index:1100;
	}
	.addExamContent{
		width: 600px;
		height: 700px;
		position: fixed;
		background:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:101;
		box-sizing: border-box;
		padding:30px;
		overflow-y: auto;
	}
	.batchModifyContent{
		width: 600px;
		height: 780px;
		position: fixed;
		background:#fff;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		z-index:101;
		box-sizing: border-box;
		padding:30px;
		overflow-y: auto;
	}
	.addExamContent h3{
		font-size:18px;
		padding:10px 0 30px;
	}
	.addExamContent ul li{
		display: flex;
		align-items: center;
		padding-bottom:15px;
	}
	.addExamContent ul li span{
		font-size:14px;
		display: flex;
		align-items: center;
		width:100px;
		justify-content: left;
	}
	.batchModifyContent ul li span{
		display: inline-block;
		width:100px;
	}
	.batchModifyContent ul li{
		margin-bottom:20px;
	}
	.addExamContent ul li span i{
		font-style:normal;
		color:red;
		padding-left:5px;
	}
	.addExamContent ul li p{
		position: relative;
	}
	.addExamContent ul li p em{
		position: absolute;
		right:10px;
		top:50%;
		transform: translateY(-50%);
		color:#C0C4CC;
		cursor: pointer;
	}
	.addExamContent ul li >>> .el-input,.addExamContent ul li >>> .el-textarea{
		width:350px;
	}
	.batchModifyContent ul li >>> .el-input,.batchModifyContent ul li >>> .el-textarea{
		width:260px;
	}
	.batchModifyContent ul li b{
		color:#1664FF;
		cursor: pointer;
		font-size:14px;
	}
	.groupbutton{
		display: flex;
		align-items: center;
		padding-top:30px;
	}
	.groupbutton >>> .el-button{
		background:#165DFF;
		width:100px;
		margin-right:20px;
	}
	.boxmain >>> .el-table .warning-row {
	    background: rgb(243, 247, 255);
	}
	.boxmain >>> .el-table .success-row {
	    background:#fff;
	}
	.boxmain >>> .el-table .el-table__header-wrapper thead th {
	  background-color:rgb(220, 231, 255); /* 设置你想要的背景颜色 */
	  color: #000000; /* 设置你想要的文字颜色 */
	}
	.missanexam{
		width: 634px;
		height: 272px;
		border-radius: 4px;
		background:#fff;
		position:fixed;
		left:50%;
		top:50%;
		transform: translate(-50%,-50%);
		box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.3);
		z-index:1100;
		box-sizing: border-box;
		padding:0 30px;
	}
	.missanexam h3{
		text-align: center;
		padding:24px 0;
		font-size:14px;
		font-weight: normal;
	}
	.missanexam h3 i{
		font-style:normal;
		color:rgb(255, 125, 0);
		font-size:16px;
		display: inline-block;
		padding-right:6px;
	}
	.missanexam p{
		text-align: center;
		font-size:14px;
		padding-bottom:24px;
	}
	.missanexam >>> .el-radio{
		margin-top:30px;
	}
	.boxbutton{
		display: flex;
		justify-content: center;
		padding-top:24px;
	}
	.boxbutton >>> .el-button:last-child{
		margin-left:30px;
	}
	.chooseschool div{
		display: flex;
		align-items: center;
		position:relative;
		margin-right:20px;
	}
	.chooseschool div:last-child{
		margin-right:0;
		margin-left:0
	}
	.chooseschool div >>> .el-input{
		width:133px;
		margin-left:20px;
	}
	.chooseschool div b{
		position:absolute;
		right:38px;
		top:50%;
		transform: translateY(-50%);
		cursor: pointer;
	}
	.modifyThreetab{
		width:208px;
		background:rgb(242, 243, 245);
		height: 30px;
		display: flex;
		line-height:30px;
		margin:20px 0;
		padding:2px;
	}
	.modifyThreetab p{
		padding:0 10px;
		cursor: pointer;
	}
	.modifyThreetab p:hover,.modifyThreetab p.hover{
		background:#fff;
		color:#0052D9
	}
	.uploadImages1{
		position:relative;
		padding-top:0;
		cursor: pointer;
	}
	.uploadImages1 span{
		box-sizing: border-box;
		display: block;
		width:100%;
		background:none;
		cursor: pointer;
		margin:0 auto;
		border-radius:6px;
		text-align:center;
		font-size:14px;
		color:#1664FF;
		cursor: pointer;
		font-weight: normal;
	}
	.uploadImages1 input{
		background:none;
		position:absolute;
		left:50%;
		top:0;
		opacity: 0;
		z-index:2;
		color: #000;
		cursor: pointer;
		height:20px;
		transform: translateX(-50%);
		width:100%;
		cursor: pointer;
	}
	.table-container {
	    overflow-y: auto;
	   border:1px solid #EBEEF5; 
	    margin: 20px 0;
	}
	
	.table-container  table {
	    border-collapse: collapse;
	}
	
	.table-container  thead th {
	    position: sticky; /* This makes the header sticky */
	    top: 0; /* Top position of the sticky header */
	    background-color:rgb(220, 231, 255); /* Header background color */
	    border-bottom:1px solid #EBEEF5; /* Bottom border to separate header from body */
	    padding: 10px;
	    text-align: left;
		z-index:1000
	}
	
	.table-container tbody td {
		width:100px;
	    padding: 10px;
	    border-bottom: 1px solid #EBEEF5;
	}
	.table-container tbody tr:nth-child(2n){
		background:rgb(243, 247, 255)
	}
	.table-container tbody td >>> input,.table-container tbody th >>> input{
		border:1px solid #dcdfe6;
	}
	.table-container tbody td div span{
		display:inline-block;
		color:#366EF4;
		margin-right:15px;
		cursor: pointer;
	}
	.table-container tbody td div span:last-child{
		color:#EA0000
	}
	.sticky-col {
	    position: -webkit-sticky; /* Safari */
	    position: sticky;
	    right: 0;
	    background: #fff;
	    z-index: 100; /* Make sure this column stays on top */
		box-shadow:0 0 0 rgba(0,0,0,0.5)
	  }
	  .emptyBox{
	  	position:relative;
	  		padding-top:100px;
	  }
	  .emptyBox p{
	  	/* position:absolute;
	  	left:50%;
	  	top:40%;
	  	transform:translate(-50%,-50%); */
	  	text-align:center;
	  }
	  .emptyBox p span{
	  	display:block;
	  	padding-top:30px;
	  }
	  .width240{
		  width:240px;
		  padding:10px;
		  box-shadow: -2px 0px 0px rgba(0,0,0,0.1)
	  }
	  .width190{
	  		  width:190px;
			 padding:10px;
			 box-shadow: -2px 0px 0px rgba(0,0,0,0.1) 
	  }
	  .boxpagelist{
		  display: flex;
		  align-items: center;
	  }
	  .boxpagelist >>> .el-pagination__total{
		  display: none !important;
	  }
	  .colorGray{
		  font-size:12px;
		  color:#999;
	  }
	  .boxpagelist >>> .el-pagination__jump{
		  color:#999;
		  font-size:12px;
	  }
	  .boxpagelist >>> .el-pagination__sizes .boxpagelist >>> .el-input .boxpagelist >>> .el-input__inner{
		  font-size:12px;
	  }
	  .boxpagelist >>> .el-pagination.is-background  .boxpagelist >>> .el-pager li:not(.disabled).active{
		 background-color:#1664FF !important
	  }
</style>